{include file="public/layout" /}

<body class="bodystyle" style="overflow-y: scroll;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="member/left" /}

<div class="page" style="min-width:auto;margin-left:100px;">
    <div class="fixed-bar">
        <div class="item-title">
            <a class="back_xin" href="{:url('UsersMoneyRechargeType/index')}" title="返回"><i class="iconfont e-fanhui"></i></a>
            <div class="subject">
                <h3>充值活动</h3>
                <h5></h5>
            </div>
        </div>
    </div>
    <div class="flexigrid">
        <form class="form-horizontal" id="postForm" action="{:url('UsersMoneyRechargeType/add')}" method="post">
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label for="title"><em>*</em>活动名称</label>
                    </dt>
                    <dd class="opt">
                        <input id="title" name="title" value="" autocomplete="off" type="text" style="width: 200px;"/>&nbsp;
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="money"><em>*</em>充值金额</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="money" id="money" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');" style="width: 200px;">元
                        <p class="notic"></p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="give_money">奖励金额</label>
                    </dt>
                    <dd class="opt">
                        <input id="give_money" name="give_money" value="" autocomplete="off" type="text" style="width: 60px;" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"/>元
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="give_score">奖励积分</label>
                    </dt>
                    <dd class="opt">
                        <input name="give_score" autocomplete="off" type="text" style="width: 60px;" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"/>
                    </dd>
                </dl>
            </div>

            <div class="ncap-form-default">
                <dl class="row">
                    <div class="bot">
                        <a href="JavaScript:void(0);" onclick="checkSubmit();" class="ncap-btn-big ncap-btn-green"
                           id="submitBtn">确认提交</a>
                    </div>
                </dl>
            </div>
        </form>
    </div>
</div>
<script>

    function checkSubmit() {
        if($('input[name=title]').val() == ''){
            showErrorMsg('活动名称不能为空！');
            $('input[name=title]').focus();
            return false;
        }
        if($('input[name=money]').val() == ''){
            showErrorMsg('奖励条件值不能为空！');
            $('input[name=money]').focus();
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : "{:url('UsersMoneyRechargeType/add', ['_ajax'=>1])}",
            data : $('#postForm').serialize(),
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, shade: layer_shade, time: 1000}, function(){
                        window.location.href = res.url;
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }
</script>
{include file="public/footer" /}